package com.itheima.controller;

import com.itheima.pojo.Dept;
import com.itheima.pojo.Job;
import com.itheima.pojo.Result;
import com.itheima.service.JobService;
import com.itheima.service.impl.DeptServiceImpl;
import com.itheima.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.logging.Logger;
@Slf4j
@RestController
public class JobController {

    @Autowired
    private JobService jobService;
    //private static Logger log= LoggerFactory.getILogger(DeptController.class);
    // @RequestMapping(value = "/depts",method = )
    @GetMapping("/jobs")
    public Result list(){
        log.info("查询全部职位数据");
        List<Job> jobList= jobService.list();
        return Result.success(jobList);
    }
    @DeleteMapping("/jobs/{id}")
    public Result delete(@PathVariable Integer id){
        log.info("根据id删除职位:{}",id);
        jobService.delete(id);
        return Result.success();
    }
    @PostMapping("/jobs")
    public Result add(@RequestBody Job job){
        System.out.println(job);
        log.info("新增部门:{}",job);
        jobService.add(job);
        return Result.success();
    }
    @GetMapping("/jobs/{id}")
    public Result find1(@PathVariable Integer id){
        log.info("根据id查询职位:{}",id);

        Job job=jobService.find2(id);
        return Result.success(job);
    }
    @PutMapping("/jobs")
    public Result update1(@RequestBody Job job){
        log.info("修改职位为:{}",job)    ;
        jobService.update2(job);
        return Result.success();
    }

}
